
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 07/13/2010 13:39:53
-- Generated from EDMX file: D:\Programação\Repositório\ProcelEntityFramework\ProcelNasEscolas.Data\Modelo.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [ProcelNasEscolasBanco];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_TurmaDataEscolaData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_TurmaData] DROP CONSTRAINT [FK_TurmaDataEscolaData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestaoBaseRespostaBase]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QuestaoDataSet] DROP CONSTRAINT [FK_QuestaoBaseRespostaBase];
GO
IF OBJECT_ID(N'[dbo].[FK_IEntidadeDataIQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet] DROP CONSTRAINT [FK_IEntidadeDataIQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestaoDataIQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QuestaoDataSet] DROP CONSTRAINT [FK_QuestaoDataIQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaAcompanhamentoEscolaDataProfessorData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData] DROP CONSTRAINT [FK_FichaAcompanhamentoEscolaDataProfessorData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaAvaliacaoCursoCapacitacaoDataEscolaData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData] DROP CONSTRAINT [FK_FichaAvaliacaoCursoCapacitacaoDataEscolaData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaCadastroDaEscolaDataProfessorData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData] DROP CONSTRAINT [FK_FichaCadastroDaEscolaDataProfessorData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaReuniaoAcompanhamentoDataConcessionariaData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData] DROP CONSTRAINT [FK_FichaReuniaoAcompanhamentoDataConcessionariaData];
GO
IF OBJECT_ID(N'[dbo].[FK_TurmaDataAlunoData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_AlunoData] DROP CONSTRAINT [FK_TurmaDataAlunoData];
GO
IF OBJECT_ID(N'[dbo].[FK_RespostaAlternativaDataAlternativas]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AlternativasSet] DROP CONSTRAINT [FK_RespostaAlternativaDataAlternativas];
GO
IF OBJECT_ID(N'[dbo].[FK_TurmaData_inherits_IEntidadeData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_TurmaData] DROP CONSTRAINT [FK_TurmaData_inherits_IEntidadeData];
GO
IF OBJECT_ID(N'[dbo].[FK_EscolaData_inherits_IEntidadeData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_EscolaData] DROP CONSTRAINT [FK_EscolaData_inherits_IEntidadeData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaAcompanhamentoEscolaData_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData] DROP CONSTRAINT [FK_FichaAcompanhamentoEscolaData_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_ProfessorData_inherits_IEntidadeData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData] DROP CONSTRAINT [FK_ProfessorData_inherits_IEntidadeData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaAvaliacaoCursoCapacitacaoData_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData] DROP CONSTRAINT [FK_FichaAvaliacaoCursoCapacitacaoData_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaCadastroDaEscolaData_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData] DROP CONSTRAINT [FK_FichaCadastroDaEscolaData_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_FichaReuniaoAcompanhamentoData_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData] DROP CONSTRAINT [FK_FichaReuniaoAcompanhamentoData_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_ConcessionariaData_inherits_IEntidadeData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_ConcessionariaData] DROP CONSTRAINT [FK_ConcessionariaData_inherits_IEntidadeData];
GO
IF OBJECT_ID(N'[dbo].[FK_AlunoData_inherits_IEntidadeData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IEntidadeDataSet_AlunoData] DROP CONSTRAINT [FK_AlunoData_inherits_IEntidadeData];
GO
IF OBJECT_ID(N'[dbo].[FK_RespostaAlternativaData_inherits_RespostaBaseData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaAlternativaData] DROP CONSTRAINT [FK_RespostaAlternativaData_inherits_RespostaBaseData];
GO
IF OBJECT_ID(N'[dbo].[FK_RespostaConsumoData_inherits_RespostaBaseData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaConsumoData] DROP CONSTRAINT [FK_RespostaConsumoData_inherits_RespostaBaseData];
GO
IF OBJECT_ID(N'[dbo].[FK_RespostaNumericaData_inherits_RespostaBaseData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaNumericaData] DROP CONSTRAINT [FK_RespostaNumericaData_inherits_RespostaBaseData];
GO
IF OBJECT_ID(N'[dbo].[FK_RespostaTextoData_inherits_RespostaBaseData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaTextoData] DROP CONSTRAINT [FK_RespostaTextoData_inherits_RespostaBaseData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestionarioAlunosTreinados1Data_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data] DROP CONSTRAINT [FK_QuestionarioAlunosTreinados1Data_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestionarioAlunosTreinados2Data_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data] DROP CONSTRAINT [FK_QuestionarioAlunosTreinados2Data_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestionarioControle1Data_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle1Data] DROP CONSTRAINT [FK_QuestionarioControle1Data_inherits_IQuestionarioData];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestionarioControle2Data_inherits_IQuestionarioData]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle2Data] DROP CONSTRAINT [FK_QuestionarioControle2Data_inherits_IQuestionarioData];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[RespostaBaseDataSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RespostaBaseDataSet];
GO
IF OBJECT_ID(N'[dbo].[QuestaoDataSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[QuestaoDataSet];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet];
GO
IF OBJECT_ID(N'[dbo].[AlternativasSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AlternativasSet];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet_TurmaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet_TurmaData];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet_EscolaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet_EscolaData];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet_ProfessorData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet_ProfessorData];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet_ConcessionariaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet_ConcessionariaData];
GO
IF OBJECT_ID(N'[dbo].[IEntidadeDataSet_AlunoData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IEntidadeDataSet_AlunoData];
GO
IF OBJECT_ID(N'[dbo].[RespostaBaseDataSet_RespostaAlternativaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RespostaBaseDataSet_RespostaAlternativaData];
GO
IF OBJECT_ID(N'[dbo].[RespostaBaseDataSet_RespostaConsumoData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RespostaBaseDataSet_RespostaConsumoData];
GO
IF OBJECT_ID(N'[dbo].[RespostaBaseDataSet_RespostaNumericaData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RespostaBaseDataSet_RespostaNumericaData];
GO
IF OBJECT_ID(N'[dbo].[RespostaBaseDataSet_RespostaTextoData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RespostaBaseDataSet_RespostaTextoData];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_QuestionarioControle1Data]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle1Data];
GO
IF OBJECT_ID(N'[dbo].[IQuestionarioDataSet_QuestionarioControle2Data]', 'U') IS NOT NULL
    DROP TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle2Data];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'RespostaBaseDataSet'
CREATE TABLE [dbo].[RespostaBaseDataSet] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'QuestaoDataSet'
CREATE TABLE [dbo].[QuestaoDataSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Enunciado] nvarchar(max)  NOT NULL,
    [IsAnswered] bit  NOT NULL,
    [RespostaBase_Id] int  NOT NULL,
    [QuestaoDataIQuestionarioData_QuestaoData_Id] int  NULL
);
GO

-- Creating table 'IEntidadeDataSet'
CREATE TABLE [dbo].[IEntidadeDataSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nome] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet'
CREATE TABLE [dbo].[IQuestionarioDataSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DataDePreenchimento] datetime  NOT NULL,
    [IEntidadeData_Id] int  NOT NULL
);
GO

-- Creating table 'AlternativasSet'
CREATE TABLE [dbo].[AlternativasSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Valor] bit  NOT NULL,
    [RespostaAlternativaDataAlternativas_Alternativas_Id] int  NOT NULL
);
GO

-- Creating table 'IEntidadeDataSet_TurmaData'
CREATE TABLE [dbo].[IEntidadeDataSet_TurmaData] (
    [Id] int  NOT NULL,
    [EscolaData_Id] int  NOT NULL
);
GO

-- Creating table 'IEntidadeDataSet_EscolaData'
CREATE TABLE [dbo].[IEntidadeDataSet_EscolaData] (
    [DataDePreenchimento] datetime  NOT NULL,
    [Telefone] nvarchar(max)  NOT NULL,
    [Diretor] nvarchar(max)  NOT NULL,
    [HoraInicioExpediente] datetime  NOT NULL,
    [HoraFimExpediente] datetime  NOT NULL,
    [NomeContatoProcel] nvarchar(max)  NOT NULL,
    [TelefoneContatoProcel] nvarchar(max)  NOT NULL,
    [Endereco] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_FichaAcompanhamentoEscolaData'
CREATE TABLE [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IEntidadeDataSet_ProfessorData'
CREATE TABLE [dbo].[IEntidadeDataSet_ProfessorData] (
    [MateriaLecionada] nvarchar(max)  NOT NULL,
    [Telefone] nvarchar(max)  NOT NULL,
    [Email] nvarchar(max)  NOT NULL,
    [PeriodoDeTrabalho] nvarchar(max)  NOT NULL,
    [DesenvolveProjetosFocadosEmEducacaoAmbiental] bit  NOT NULL,
    [LevouTemaParaSalaDeAula] bit  NOT NULL,
    [NivelDeEnsino] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL,
    [FichaAcompanhamentoEscolaDataProfessorData_ProfessorData_Id] int  NULL,
    [FichaCadastroDaEscolaDataProfessorData_ProfessorData_Id] int  NULL
);
GO

-- Creating table 'IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData'
CREATE TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData] (
    [SeriesLecionadas] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL,
    [EscolaData_Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_FichaCadastroDaEscolaData'
CREATE TABLE [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_FichaReuniaoAcompanhamentoData'
CREATE TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData] (
    [DataPrimeiraReunião] datetime  NOT NULL,
    [DataSegundaReunião] datetime  NOT NULL,
    [Id] int  NOT NULL,
    [ConcessionariaData_Id] int  NOT NULL
);
GO

-- Creating table 'IEntidadeDataSet_ConcessionariaData'
CREATE TABLE [dbo].[IEntidadeDataSet_ConcessionariaData] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IEntidadeDataSet_AlunoData'
CREATE TABLE [dbo].[IEntidadeDataSet_AlunoData] (
    [Endereco] nvarchar(max)  NOT NULL,
    [Idade] int  NOT NULL,
    [Telefone] nvarchar(max)  NOT NULL,
    [DataDeCadastro] datetime  NOT NULL,
    [Id] int  NOT NULL,
    [TurmaData_Id] int  NOT NULL
);
GO

-- Creating table 'RespostaBaseDataSet_RespostaAlternativaData'
CREATE TABLE [dbo].[RespostaBaseDataSet_RespostaAlternativaData] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'RespostaBaseDataSet_RespostaConsumoData'
CREATE TABLE [dbo].[RespostaBaseDataSet_RespostaConsumoData] (
    [MesAno] datetime  NOT NULL,
    [KWh] decimal(18,0)  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'RespostaBaseDataSet_RespostaNumericaData'
CREATE TABLE [dbo].[RespostaBaseDataSet_RespostaNumericaData] (
    [Valor] decimal(18,0)  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'RespostaBaseDataSet_RespostaTextoData'
CREATE TABLE [dbo].[RespostaBaseDataSet_RespostaTextoData] (
    [Valor] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_QuestionarioAlunosTreinados1Data'
CREATE TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_QuestionarioAlunosTreinados2Data'
CREATE TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_QuestionarioControle1Data'
CREATE TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle1Data] (
    [Id] int  NOT NULL
);
GO

-- Creating table 'IQuestionarioDataSet_QuestionarioControle2Data'
CREATE TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle2Data] (
    [Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'RespostaBaseDataSet'
ALTER TABLE [dbo].[RespostaBaseDataSet]
ADD CONSTRAINT [PK_RespostaBaseDataSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'QuestaoDataSet'
ALTER TABLE [dbo].[QuestaoDataSet]
ADD CONSTRAINT [PK_QuestaoDataSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet'
ALTER TABLE [dbo].[IEntidadeDataSet]
ADD CONSTRAINT [PK_IEntidadeDataSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet'
ALTER TABLE [dbo].[IQuestionarioDataSet]
ADD CONSTRAINT [PK_IQuestionarioDataSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'AlternativasSet'
ALTER TABLE [dbo].[AlternativasSet]
ADD CONSTRAINT [PK_AlternativasSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet_TurmaData'
ALTER TABLE [dbo].[IEntidadeDataSet_TurmaData]
ADD CONSTRAINT [PK_IEntidadeDataSet_TurmaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet_EscolaData'
ALTER TABLE [dbo].[IEntidadeDataSet_EscolaData]
ADD CONSTRAINT [PK_IEntidadeDataSet_EscolaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_FichaAcompanhamentoEscolaData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData]
ADD CONSTRAINT [PK_IQuestionarioDataSet_FichaAcompanhamentoEscolaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet_ProfessorData'
ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData]
ADD CONSTRAINT [PK_IEntidadeDataSet_ProfessorData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]
ADD CONSTRAINT [PK_IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_FichaCadastroDaEscolaData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData]
ADD CONSTRAINT [PK_IQuestionarioDataSet_FichaCadastroDaEscolaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_FichaReuniaoAcompanhamentoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]
ADD CONSTRAINT [PK_IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet_ConcessionariaData'
ALTER TABLE [dbo].[IEntidadeDataSet_ConcessionariaData]
ADD CONSTRAINT [PK_IEntidadeDataSet_ConcessionariaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IEntidadeDataSet_AlunoData'
ALTER TABLE [dbo].[IEntidadeDataSet_AlunoData]
ADD CONSTRAINT [PK_IEntidadeDataSet_AlunoData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'RespostaBaseDataSet_RespostaAlternativaData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaAlternativaData]
ADD CONSTRAINT [PK_RespostaBaseDataSet_RespostaAlternativaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'RespostaBaseDataSet_RespostaConsumoData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaConsumoData]
ADD CONSTRAINT [PK_RespostaBaseDataSet_RespostaConsumoData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'RespostaBaseDataSet_RespostaNumericaData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaNumericaData]
ADD CONSTRAINT [PK_RespostaBaseDataSet_RespostaNumericaData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'RespostaBaseDataSet_RespostaTextoData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaTextoData]
ADD CONSTRAINT [PK_RespostaBaseDataSet_RespostaTextoData]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_QuestionarioAlunosTreinados1Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data]
ADD CONSTRAINT [PK_IQuestionarioDataSet_QuestionarioAlunosTreinados1Data]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_QuestionarioAlunosTreinados2Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data]
ADD CONSTRAINT [PK_IQuestionarioDataSet_QuestionarioAlunosTreinados2Data]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_QuestionarioControle1Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle1Data]
ADD CONSTRAINT [PK_IQuestionarioDataSet_QuestionarioControle1Data]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'IQuestionarioDataSet_QuestionarioControle2Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle2Data]
ADD CONSTRAINT [PK_IQuestionarioDataSet_QuestionarioControle2Data]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [EscolaData_Id] in table 'IEntidadeDataSet_TurmaData'
ALTER TABLE [dbo].[IEntidadeDataSet_TurmaData]
ADD CONSTRAINT [FK_TurmaDataEscolaData]
    FOREIGN KEY ([EscolaData_Id])
    REFERENCES [dbo].[IEntidadeDataSet_EscolaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TurmaDataEscolaData'
CREATE INDEX [IX_FK_TurmaDataEscolaData]
ON [dbo].[IEntidadeDataSet_TurmaData]
    ([EscolaData_Id]);
GO

-- Creating foreign key on [RespostaBase_Id] in table 'QuestaoDataSet'
ALTER TABLE [dbo].[QuestaoDataSet]
ADD CONSTRAINT [FK_QuestaoBaseRespostaBase]
    FOREIGN KEY ([RespostaBase_Id])
    REFERENCES [dbo].[RespostaBaseDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_QuestaoBaseRespostaBase'
CREATE INDEX [IX_FK_QuestaoBaseRespostaBase]
ON [dbo].[QuestaoDataSet]
    ([RespostaBase_Id]);
GO

-- Creating foreign key on [IEntidadeData_Id] in table 'IQuestionarioDataSet'
ALTER TABLE [dbo].[IQuestionarioDataSet]
ADD CONSTRAINT [FK_IEntidadeDataIQuestionarioData]
    FOREIGN KEY ([IEntidadeData_Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_IEntidadeDataIQuestionarioData'
CREATE INDEX [IX_FK_IEntidadeDataIQuestionarioData]
ON [dbo].[IQuestionarioDataSet]
    ([IEntidadeData_Id]);
GO

-- Creating foreign key on [QuestaoDataIQuestionarioData_QuestaoData_Id] in table 'QuestaoDataSet'
ALTER TABLE [dbo].[QuestaoDataSet]
ADD CONSTRAINT [FK_QuestaoDataIQuestionarioData]
    FOREIGN KEY ([QuestaoDataIQuestionarioData_QuestaoData_Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_QuestaoDataIQuestionarioData'
CREATE INDEX [IX_FK_QuestaoDataIQuestionarioData]
ON [dbo].[QuestaoDataSet]
    ([QuestaoDataIQuestionarioData_QuestaoData_Id]);
GO

-- Creating foreign key on [FichaAcompanhamentoEscolaDataProfessorData_ProfessorData_Id] in table 'IEntidadeDataSet_ProfessorData'
ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData]
ADD CONSTRAINT [FK_FichaAcompanhamentoEscolaDataProfessorData]
    FOREIGN KEY ([FichaAcompanhamentoEscolaDataProfessorData_ProfessorData_Id])
    REFERENCES [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FichaAcompanhamentoEscolaDataProfessorData'
CREATE INDEX [IX_FK_FichaAcompanhamentoEscolaDataProfessorData]
ON [dbo].[IEntidadeDataSet_ProfessorData]
    ([FichaAcompanhamentoEscolaDataProfessorData_ProfessorData_Id]);
GO

-- Creating foreign key on [EscolaData_Id] in table 'IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]
ADD CONSTRAINT [FK_FichaAvaliacaoCursoCapacitacaoDataEscolaData]
    FOREIGN KEY ([EscolaData_Id])
    REFERENCES [dbo].[IEntidadeDataSet_EscolaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FichaAvaliacaoCursoCapacitacaoDataEscolaData'
CREATE INDEX [IX_FK_FichaAvaliacaoCursoCapacitacaoDataEscolaData]
ON [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]
    ([EscolaData_Id]);
GO

-- Creating foreign key on [FichaCadastroDaEscolaDataProfessorData_ProfessorData_Id] in table 'IEntidadeDataSet_ProfessorData'
ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData]
ADD CONSTRAINT [FK_FichaCadastroDaEscolaDataProfessorData]
    FOREIGN KEY ([FichaCadastroDaEscolaDataProfessorData_ProfessorData_Id])
    REFERENCES [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FichaCadastroDaEscolaDataProfessorData'
CREATE INDEX [IX_FK_FichaCadastroDaEscolaDataProfessorData]
ON [dbo].[IEntidadeDataSet_ProfessorData]
    ([FichaCadastroDaEscolaDataProfessorData_ProfessorData_Id]);
GO

-- Creating foreign key on [ConcessionariaData_Id] in table 'IQuestionarioDataSet_FichaReuniaoAcompanhamentoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]
ADD CONSTRAINT [FK_FichaReuniaoAcompanhamentoDataConcessionariaData]
    FOREIGN KEY ([ConcessionariaData_Id])
    REFERENCES [dbo].[IEntidadeDataSet_ConcessionariaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FichaReuniaoAcompanhamentoDataConcessionariaData'
CREATE INDEX [IX_FK_FichaReuniaoAcompanhamentoDataConcessionariaData]
ON [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]
    ([ConcessionariaData_Id]);
GO

-- Creating foreign key on [TurmaData_Id] in table 'IEntidadeDataSet_AlunoData'
ALTER TABLE [dbo].[IEntidadeDataSet_AlunoData]
ADD CONSTRAINT [FK_TurmaDataAlunoData]
    FOREIGN KEY ([TurmaData_Id])
    REFERENCES [dbo].[IEntidadeDataSet_TurmaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TurmaDataAlunoData'
CREATE INDEX [IX_FK_TurmaDataAlunoData]
ON [dbo].[IEntidadeDataSet_AlunoData]
    ([TurmaData_Id]);
GO

-- Creating foreign key on [RespostaAlternativaDataAlternativas_Alternativas_Id] in table 'AlternativasSet'
ALTER TABLE [dbo].[AlternativasSet]
ADD CONSTRAINT [FK_RespostaAlternativaDataAlternativas]
    FOREIGN KEY ([RespostaAlternativaDataAlternativas_Alternativas_Id])
    REFERENCES [dbo].[RespostaBaseDataSet_RespostaAlternativaData]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RespostaAlternativaDataAlternativas'
CREATE INDEX [IX_FK_RespostaAlternativaDataAlternativas]
ON [dbo].[AlternativasSet]
    ([RespostaAlternativaDataAlternativas_Alternativas_Id]);
GO

-- Creating foreign key on [Id] in table 'IEntidadeDataSet_TurmaData'
ALTER TABLE [dbo].[IEntidadeDataSet_TurmaData]
ADD CONSTRAINT [FK_TurmaData_inherits_IEntidadeData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IEntidadeDataSet_EscolaData'
ALTER TABLE [dbo].[IEntidadeDataSet_EscolaData]
ADD CONSTRAINT [FK_EscolaData_inherits_IEntidadeData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_FichaAcompanhamentoEscolaData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAcompanhamentoEscolaData]
ADD CONSTRAINT [FK_FichaAcompanhamentoEscolaData_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IEntidadeDataSet_ProfessorData'
ALTER TABLE [dbo].[IEntidadeDataSet_ProfessorData]
ADD CONSTRAINT [FK_ProfessorData_inherits_IEntidadeData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaAvaliacaoCursoCapacitacaoData]
ADD CONSTRAINT [FK_FichaAvaliacaoCursoCapacitacaoData_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_FichaCadastroDaEscolaData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaCadastroDaEscolaData]
ADD CONSTRAINT [FK_FichaCadastroDaEscolaData_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_FichaReuniaoAcompanhamentoData'
ALTER TABLE [dbo].[IQuestionarioDataSet_FichaReuniaoAcompanhamentoData]
ADD CONSTRAINT [FK_FichaReuniaoAcompanhamentoData_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IEntidadeDataSet_ConcessionariaData'
ALTER TABLE [dbo].[IEntidadeDataSet_ConcessionariaData]
ADD CONSTRAINT [FK_ConcessionariaData_inherits_IEntidadeData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IEntidadeDataSet_AlunoData'
ALTER TABLE [dbo].[IEntidadeDataSet_AlunoData]
ADD CONSTRAINT [FK_AlunoData_inherits_IEntidadeData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IEntidadeDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'RespostaBaseDataSet_RespostaAlternativaData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaAlternativaData]
ADD CONSTRAINT [FK_RespostaAlternativaData_inherits_RespostaBaseData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[RespostaBaseDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'RespostaBaseDataSet_RespostaConsumoData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaConsumoData]
ADD CONSTRAINT [FK_RespostaConsumoData_inherits_RespostaBaseData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[RespostaBaseDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'RespostaBaseDataSet_RespostaNumericaData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaNumericaData]
ADD CONSTRAINT [FK_RespostaNumericaData_inherits_RespostaBaseData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[RespostaBaseDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'RespostaBaseDataSet_RespostaTextoData'
ALTER TABLE [dbo].[RespostaBaseDataSet_RespostaTextoData]
ADD CONSTRAINT [FK_RespostaTextoData_inherits_RespostaBaseData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[RespostaBaseDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_QuestionarioAlunosTreinados1Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados1Data]
ADD CONSTRAINT [FK_QuestionarioAlunosTreinados1Data_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_QuestionarioAlunosTreinados2Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioAlunosTreinados2Data]
ADD CONSTRAINT [FK_QuestionarioAlunosTreinados2Data_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_QuestionarioControle1Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle1Data]
ADD CONSTRAINT [FK_QuestionarioControle1Data_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'IQuestionarioDataSet_QuestionarioControle2Data'
ALTER TABLE [dbo].[IQuestionarioDataSet_QuestionarioControle2Data]
ADD CONSTRAINT [FK_QuestionarioControle2Data_inherits_IQuestionarioData]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[IQuestionarioDataSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------